package com.bawei.week.fragment

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.launcher.ARouter
import com.bawei.lib_base.mvvm.BaseFragment
import com.bawei.lib_base.mvvm.BaseViewFragment
import com.bawei.week.R
import com.bawei.week.adapter.NoticeAdapter
import com.bawei.week.databinding.FragmentHomeBinding
import com.bawei.week.notice.NoticeViewModel
import dagger.hilt.android.AndroidEntryPoint
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch

@AndroidEntryPoint
class HomeFragment : BaseFragment<FragmentHomeBinding,NoticeViewModel>() {
    val noticeAdapter by lazy { NoticeAdapter() }
    override fun initView() {
        binding.rvNotice.apply {
            adapter = noticeAdapter
            layoutManager = LinearLayoutManager(requireContext())
        }

        lifecycleScope.launch {
            vm.getNoticeByType().collect{
                noticeAdapter.submitData(it)
            }
        }

        binding.llSign.setOnClickListener {
            ARouter.getInstance().build("/app/SingActivity").navigation()
        }
    }

    override fun initData() {

    }
}